package com.example.clientmanage

import androidx.appcompat.app.AppCompatActivity
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import androidx.appcompat.widget.Toolbar
import com.example.clientmanage.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
    private lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)
        
        // 设置工具栏标题
        binding.toolbar.title = "客户端管理"
        setSupportActionBar(binding.toolbar)
        
        // 设置退出按钮点击事件
        binding.btnLogout.setOnClickListener {
            // 创建Intent跳转到LoginActivity
            val intent = Intent(this, LoginActivity::class.java)
            // 添加标志清除所有活动堆栈
            intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
            // 启动登录界面
            startActivity(intent)
            // 结束当前活动
            finish()
        }
    }
}